//
//  StatusListModel.swift
//  01-WeiBo
//
//  Created by 李晓东 on 17/7/7.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

import UIKit

class StatusListModel {
    
    lazy var listModel = [StatusModel]()
    
    func loadStatus(finishCallback:@escaping (_ isSuccessed : Bool) -> (Void)) {
        NetWorkingTools.shareNetWorkingTools.loadWeiboInfo { (result, error) in
            if error != nil {
                finishCallback(false)
                return
            }
            
            print("done")
            
            guard let allResult = result as? [String:AnyObject] else {
                finishCallback(false)
                return
            }
            
            let results = allResult["statuses"]
            for status in results as! [[String:AnyObject]] {
                let statusObj = Status(dict: status)
                let statusModel = StatusModel(status: statusObj)
                print(statusObj)
                self.listModel.append(statusModel)
                finishCallback(true)
            }
        }
    }
}
